from fastapi import APIRouter

from app.database.postgre import SessionDep
from app.models.common import TrialRecordIdJSON
from app.models.trial_records import AppTrialRecordListParams, UpdateTrialCountJSON
from app.services import accounts, trial_records

router = APIRouter(
    prefix='/api/v1/trial_records',
    tags=['backend', 'trial_records']
)


@router.get('/list')
async def trial_records_list(
        account: accounts.LoggedInAccount,
        query_params: AppTrialRecordListParams,
        session: SessionDep):
    response = await trial_records.get_trial_records_list(account, query_params, session)
    return response


@router.post('/delete')
async def delete_trial_record(account: accounts.LoggedInAccount, json_data: TrialRecordIdJSON, session: SessionDep):
    response = await trial_records.delete_trial_record(account, json_data, session)
    return response


@router.post('/trial_count/update')
async def update_trial_count(account: accounts.LoggedInAccount, json_data: UpdateTrialCountJSON, session: SessionDep):
    response = await trial_records.update_record_trial_count(account, json_data, session)
    return response
